
import {$http, $request} from "./request.js";


const server = {
    // 地址相关
    addressAbout:{
        /**
         * 获取地址列表
         * @param {number} page_no: 页码
         * @param {number} page_num: 每页显示数量
         * @param {number} level: 地址等级 1 2 3
         */
        addressList: function(page_no, page_num, level){
            $http.get("address/v1.0/addressList", {
                params:{
                    page_no: page_no,
                    page_num: page_num,
                    level: level
                }    
            })
        },

        /**
         * 地址详情信息
         * @param {number} address_id: 地址id
         */
        addressInfo: function(address_id){
            $http.get("address/v1.0/addressInfo", {
                params: {
                    address_id: address_id
                }
            })
        }

    },

    hot: {
        // 热点首页
        hotSource(page=1){
            return $http.get("/v1.0/hotSource?page="+page, {"page": page})
        },
        hotInfo(hotSource){
            return $http.get("/v1.0/hotInfo?hot_source="+hotSource, {"hot_source": hotSource})
        }
    },
    joke: {
        // 获取一个笑话
        get_joke(type_){
            return $http.get(`jokes/v1.0/index?type_=${type_}`)
        }
    },
    novel: {
        //搜索小说
        search_novel(novel_name, pageNo=1, pageNum=20){
            /*
                params novel_name: 小说名称
             */
            return $http.get(`novel/v1.0/search?novel_name=${novel_name}&pageNo=${pageNo}&pageNum=${pageNum}`)
        },
        // 获取目录
        get_catalogue(book_id, type_=1){
            /**
             * params book_id: 小说id
             * params type_: 类型 对应不同的网站
             */
            return $http.get(`novel/v1.0/catalogue?book_id=${book_id}&book_type=${type_}`)
        },
        // 获取章节详情
        get_chapter_detail(book_id, chapter_id, type_=1){
            return $http.get(`novel/v1.0/detail?book_id=${book_id}&chapter_id=${chapter_id}&book_type=${type_}`)
        }
    },
    video: {
        video_random(){
            return $http.get(`v1.0/randomVideo`)
        }

    },
    user: {
        feedback(text){
            return $http.post('/user/v1.0/feedBack', {"text": text})
        }
    }
}

export default server;